package me.keiwu.admin.controller;

import com.alibaba.fastjson.JSON;
import me.keiwu.admin.rpc.ChallengeRpc;
import me.keiwu.admin.rpc.UserRpc;
import me.keiwu.pub.data.ResponseV2;
import me.keiwu.pub.data.service.UserInfoBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by kei on 28/12/2017.
 */
@RestController
public class StatisticsController {


    @Autowired
    private UserRpc userRpc;
    @Autowired
    private ChallengeRpc challengeRpc;



    public ResponseV2 userStatistics(@RequestParam(required = false) String nickName,
                                     @RequestParam(defaultValue = "0") Integer page,
                                     @RequestParam(defaultValue = "10") Integer size) {
        List<UserInfoBean> userList = JSON.parseArray(userRpc.historyLoginUser(nickName, page, size), UserInfoBean.class);
        userList.forEach(u -> {
//            challengeRpc.findAllUserChallenge()
        });
        return ResponseV2.ok();
    }

}
